import api from '../../core/apiUrl.js';
import siteInfo from '../../siteinfo.js';
const spliceUrl = (ip, apiUrl) => {
	let newUrl = {};
	for (let k in apiUrl) {
		let newOb = {
			[k]: {}
		};
		for (let i in apiUrl[k]) {
			newOb[k][i] = `${ip}${apiUrl[k][i]}`
		}
		newUrl[k] = newOb[k];
	}
	return newUrl;
};

export default {
	state: {
		mall_id:1,
		apirl:'',
		allurl:''
	},
	mutations: {
		getApiRoot(state, mall_id) {
			state.mall_id = mall_id;
			state.apirl = siteInfo.apiroot + '?_mall_id=' + mall_id + '&r=';
			// console.log(state.apirl,'apiip');
			
			state.allurl = spliceUrl(state.apirl,api)
			// console.log(state.allurl,'a;;');
		}
	},
	actions:{
		getApiRoot(state, mall_id) {
			state.mall_id = mall_id;
			state.apirl = siteInfo.apiroot + '?mall_id=' + mall_id + '&r=';
			// console.log(state.apirl,'apiip');
			
			state.allurl = spliceUrl(state.apirl,api)
			// console.log(state.allurl,'a;;');
		}
	}
}
